/*
 *  Copyright (C) 2011 Hatsites
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package org.myorg.ctm.etk.gui.swg.display.create;

import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import org.myorg.shr.gui.swg.display.labelized.LbzTxfHrz;
import org.myorg.shr.gui.swg.display.labelized.LbzHrzTextField2;
import org.myorg.shr.gui.swg.display.panel.PnlAbs;

/**
 *
 * @author Hatsites
 *
 * email: Hatsites_AT_gmail.com
 * ... please remove "_AT_" from the above string to get the right email address
 */

public class PnlAdressePostale extends PnlAbs {
    public PnlAdressePostale() {

        this._txfLigne1_ = new JTextField();
        this._txfLigne2_ = new JTextField();
        this._lblAdresse_ = new JLabel("Adresse");
        this._ltfNumero_ = new LbzHrzTextField2("N°", "Voie", 30);
        this._ltfCity_ =  new LbzHrzTextField2("Code", "Ville", 10);
        this._ltfPays_ = new LbzTxfHrz("Pays",12);
    }

    public boolean init() {
        if(!this._ltfCity_.init()){
            return false;
        }
        if(!this._ltfPays_.init()){
            return false;
        }
        if(!this._ltfNumero_.init()){
            return false;
        }
        
        this.setSize(340, 168);
        GroupLayout layout = new GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()

                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(this._ltfNumero_)
                    .addComponent(this._txfLigne2_, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                    .addComponent(this._txfLigne1_, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                    .addComponent(this._ltfCity_)
                    .addComponent(this._ltfPays_)
                     )
                )
            .addGroup(layout.createSequentialGroup()
                .addComponent(this._lblAdresse_)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(this._lblAdresse_)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._ltfNumero_)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._txfLigne1_, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._txfLigne2_, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._ltfCity_)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(this._ltfPays_)
                )
        );
        return true;
    }

    public void destroy() {
        return;
    }

    public String getAdresseNumero(){
        return this._ltfNumero_.getTextLeft();
    }

    public String getAdresseVoie(){
         return this._ltfNumero_.getTextRight();
    }

    public String getAdresseLigne1(){
         return this._txfLigne1_.getText();
    }

    public String getAdresseLigne2(){
        return this._txfLigne2_.getText();
    }

    public String getAdresseCode(){
        return this._ltfCity_.getTextLeft();
    }

    public String getAdresseVille(){
         return this._ltfCity_.getTextRight();
    }

    public String getAdressePays(){
         return this._ltfPays_.getText();
    }

    private JLabel _lblAdresse_;
    private JTextField _txfLigne1_;
    private JTextField _txfLigne2_;
    private LbzTxfHrz _ltfPays_;
    private LbzHrzTextField2 _ltfCity_;
    private LbzHrzTextField2 _ltfNumero_;

}
